﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="{x:Type Expander}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Foreground" Value="{DynamicResource ExpanderForegroundThemeBrush}" />
        <Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3" SnapsToDevicePixels="True">
                        <DockPanel>
                            <ToggleButton x:Name="HeaderSite" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" DockPanel.Dock="Top" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" MinWidth="0" MinHeight="0" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}">
                                <ToggleButton.FocusVisualStyle>
                                    <Style>
                                        <Setter Property="Control.Template">
                                            <Setter.Value>
                                                <ControlTemplate>
                                                    <Grid>
                                                        <Rectangle x:Name="FocusVisualWhite" IsHitTestVisible="False" StrokeEndLineCap="Square" Stroke="{DynamicResource FocusVisualWhiteStrokeThemeBrush}" />
                                                        <Rectangle x:Name="FocusVisualBlack" IsHitTestVisible="False" StrokeEndLineCap="Square" Stroke="{DynamicResource FocusVisualBlackStrokeThemeBrush}" />
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </ToggleButton.FocusVisualStyle>
                                <ToggleButton.Style>
                                    <Style TargetType="{x:Type ToggleButton}">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                    <Border Padding="{TemplateBinding Padding}">
                                                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="Auto" />
                                                                <ColumnDefinition Width="*" />
                                                            </Grid.ColumnDefinitions>
                                                            <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="{DynamicResource ExpanderButtonThemeHeight}" Stroke="{DynamicResource ExpanderForegroundThemeBrush}" StrokeThickness="3" VerticalAlignment="Center" Width="{DynamicResource ExpanderButtonThemeHeight}" />
                                                            <TextBlock x:Name="arrow" Foreground="{DynamicResource ExpanderArrowForegroundThemeBrush}" FontWeight="Bold" FontSize="18" FontFamily="{DynamicResource SymbolThemeFontFamily}" HorizontalAlignment="Center" IsHitTestVisible="False" Text="&#xE011;" Margin="0,-5,0,0"  VerticalAlignment="Center" />
                                                            <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="1" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center" />
                                                        </Grid>
                                                    </Border>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsChecked" Value="True">
                                                            <Setter Property="Text" TargetName="arrow" Value="&#xE010;" />
                                                            <Setter Property="Margin" TargetName="arrow" Value="0,-7,0,0" />
                                                        </Trigger>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPointerOverBackgroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsPressed" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPressedBackgroundThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderPressedArrowForegroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsEnabled" Value="False">
                                                            <Setter Property="Stroke" TargetName="circle" Value="{DynamicResource ExpanderDisabledBorderThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderDisabledForegroundThemeBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </ToggleButton.Style>
                            </ToggleButton>
                            <ContentPresenter x:Name="ExpandSite" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" DockPanel.Dock="Bottom" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible" />
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Right">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right" />
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left" />
                            <Setter Property="Style" TargetName="HeaderSite">
                                <Setter.Value>
                                    <Style TargetType="{x:Type ToggleButton}">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                    <Border Padding="{TemplateBinding Padding}">
                                                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="Auto" />
                                                                <RowDefinition Height="*" />
                                                            </Grid.RowDefinitions>
                                                            <Grid>
                                                                <Grid.LayoutTransform>
                                                                    <TransformGroup>
                                                                        <RotateTransform Angle="-90" />
                                                                    </TransformGroup>
                                                                </Grid.LayoutTransform>
                                                                <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="{DynamicResource ExpanderButtonThemeHeight}" Stroke="{DynamicResource ExpanderForegroundThemeBrush}" StrokeThickness="3" VerticalAlignment="Center" Width="{DynamicResource ExpanderButtonThemeHeight}" />
                                                                <TextBlock x:Name="arrow" Foreground="{DynamicResource ExpanderArrowForegroundThemeBrush}" FontWeight="Bold" FontSize="18" FontFamily="{DynamicResource SymbolThemeFontFamily}" HorizontalAlignment="Center" IsHitTestVisible="False" Text="&#xE011;" Margin="0,-5,0,0"  VerticalAlignment="Center" />
                                                            </Grid>
                                                            <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top" />
                                                        </Grid>
                                                    </Border>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsChecked" Value="True">
                                                            <Setter Property="Text" TargetName="arrow" Value="&#xE010;" />
                                                            <Setter Property="Margin" TargetName="arrow" Value="0,-7,0,0" />
                                                        </Trigger>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPointerOverBackgroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsPressed" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPressedBackgroundThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderPressedArrowForegroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsEnabled" Value="False">
                                                            <Setter Property="Stroke" TargetName="circle" Value="{DynamicResource ExpanderDisabledBorderThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderDisabledForegroundThemeBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Up">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top" />
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom" />
                            <Setter Property="Style" TargetName="HeaderSite">
                                <Setter.Value>
                                    <Style TargetType="{x:Type ToggleButton}">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                    <Border Padding="{TemplateBinding Padding}">
                                                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="Auto" />
                                                                <ColumnDefinition Width="*" />
                                                            </Grid.ColumnDefinitions>
                                                            <Grid>
                                                                <Grid.LayoutTransform>
                                                                    <TransformGroup>
                                                                        <RotateTransform Angle="180" />
                                                                    </TransformGroup>
                                                                </Grid.LayoutTransform>
                                                                <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="{DynamicResource ExpanderButtonThemeHeight}" Stroke="{DynamicResource ExpanderForegroundThemeBrush}" StrokeThickness="3" VerticalAlignment="Center" Width="{DynamicResource ExpanderButtonThemeHeight}" />
                                                                <TextBlock x:Name="arrow" Foreground="{DynamicResource ExpanderArrowForegroundThemeBrush}" FontWeight="Bold" FontSize="18" FontFamily="{DynamicResource SymbolThemeFontFamily}" HorizontalAlignment="Center" IsHitTestVisible="False" Text="&#xE010;" Margin="0,-5,0,0"  VerticalAlignment="Center" />
                                                            </Grid>
                                                            <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="1" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center" />
                                                        </Grid>
                                                    </Border>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsChecked" Value="True">
                                                            <Setter Property="Text" TargetName="arrow" Value="&#xE011;" />
                                                            <Setter Property="Margin" TargetName="arrow" Value="0,-7,0,0" />
                                                        </Trigger>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPointerOverBackgroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsPressed" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPressedBackgroundThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderPressedArrowForegroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsEnabled" Value="False">
                                                            <Setter Property="Stroke" TargetName="circle" Value="{DynamicResource ExpanderDisabledBorderThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderDisabledForegroundThemeBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="ExpandDirection" Value="Left">
                            <Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left" />
                            <Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right" />
                            <Setter Property="Style" TargetName="HeaderSite">
                                <Setter.Value>
                                    <Style TargetType="{x:Type ToggleButton}">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                    <Border Padding="{TemplateBinding Padding}">
                                                        <Grid Background="Transparent" SnapsToDevicePixels="False">
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="Auto" />
                                                                <RowDefinition Height="*" />
                                                            </Grid.RowDefinitions>
                                                            <Grid>
                                                                <Grid.LayoutTransform>
                                                                    <TransformGroup>
                                                                        <RotateTransform Angle="90" />
                                                                    </TransformGroup>
                                                                </Grid.LayoutTransform>
                                                                <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="{DynamicResource ExpanderButtonThemeHeight}" Stroke="{DynamicResource ExpanderForegroundThemeBrush}" StrokeThickness="3" VerticalAlignment="Center" Width="{DynamicResource ExpanderButtonThemeHeight}" />
                                                                <TextBlock x:Name="arrow" Foreground="{DynamicResource ExpanderArrowForegroundThemeBrush}" FontWeight="Bold" FontSize="18" FontFamily="{DynamicResource SymbolThemeFontFamily}" HorizontalAlignment="Center" IsHitTestVisible="False" Text="&#xE011;" Margin="0,-5,0,0"  VerticalAlignment="Center" />
                                                            </Grid>
                                                            <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="Center" Margin="0,4,0,0" Grid.Row="1" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Top" />
                                                        </Grid>
                                                    </Border>
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsChecked" Value="True">
                                                            <Setter Property="Text" TargetName="arrow" Value="&#xE010;" />
                                                            <Setter Property="Margin" TargetName="arrow" Value="0,-7,0,0" />
                                                        </Trigger>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPointerOverBackgroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsPressed" Value="True">
                                                            <Setter Property="Fill" TargetName="circle" Value="{DynamicResource ExpanderPressedBackgroundThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderPressedArrowForegroundThemeBrush}" />
                                                        </Trigger>
                                                        <Trigger Property="IsEnabled" Value="False">
                                                            <Setter Property="Stroke" TargetName="circle" Value="{DynamicResource ExpanderDisabledBorderThemeBrush}" />
                                                            <Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource ExpanderDisabledForegroundThemeBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="True">
                <Setter  Property="BorderBrush" Value="{DynamicResource ControlValidationInvalidThemeBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>